package com.zhangtong.excel.generator;

import com.zhangtong.excel.ExcelContext;
import com.zhangtong.excel.entity.ProjectWorktimeData;
import com.zhangtong.excel.entity.StatisticsData;
import com.zhangtong.excel.entity.Title;
import org.apache.poi.ss.usermodel.Row;

import java.util.TreeMap;

public class ProjectStaffGenerator implements IGenerator {

    @Override
    public void generateRows(StatisticsData statisticsData, Title title, ExcelContext context) {
        TreeMap<String, ProjectWorktimeData> data = statisticsData.getProjectStatistics();
        data.forEach((project, worktimeData) -> {
            worktimeData.getStatisticsData().forEach((name, worktime) -> {
                Row row = context.createNextRow();
                IGenerator.generateCells(name, project, worktime, title, row, context);
            });
        });
    }
}
